//
//  Powerup.m
//  fugitive
//
//  Created by Eugene Bistolas on 5/27/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "Powerup.h"


@implementation Powerup
@synthesize coordinate;
@synthesize powerupID;
@synthesize type; 

- (id) initWithPowerupID:(int) pid type:(int)t coordinate:(CLLocationCoordinate2D)coord {
   self = [self init]; 
   if (self) {
      self.powerupID = pid;
      self.type = t;
      self.coordinate = coord; 
   }
   
   return self; 
}

+ (int) generatePowerupID {
   return (arc4random() % 500); 
}

+ (CLLocationCoordinate2D) setupPowerupwithCoords:(CLLocationCoordinate2D) start endLocation: (CLLocationCoordinate2D) end {
   double lesserLat, lesserLong, diffLat, diffLong;
   double latPoint, longPoint;
   
   //gets smaller latitude
   if (start.latitude < end.latitude)
      lesserLat = start.latitude;
   else 
      lesserLat = end.latitude;
   //gets smaller longitude value
   if (start.longitude < end.longitude)
      lesserLat = start.longitude;
   else 
      lesserLat = end.longitude;
   
   //find the absolute value of differences
   diffLat = fabs(start.latitude - end.latitude);
   diffLong = fabs(start.longitude - end.longitude);
   
   latPoint = floor(((double) arc4random() / MAX_VALUE) * diffLat) + lesserLat;
   longPoint = floor(((double) arc4random() / MAX_VALUE) * diffLong) + lesserLong;
   
   CLLocationCoordinate2D powerupCoord = CLLocationCoordinate2DMake(latPoint, longPoint); 
   
   return powerupCoord;
   
   
   
}

@end
